package org.xdq.观察者模式2;

import java.util.Observable;
import java.util.Observer;

public class Police implements Observer {
    @Override
    public void update(Observable o, Object arg) {
        int status = (int)arg;
        switch(status){
            case 0:
                System.out.println("警察：一切正常。");break;
            case 1:
                System.out.println("警察：有问题。");
                new Thread(){

                    public void run() {
                        ((Security)o).警察出动();
                    }
                }.start();

                break;
            case 3:
                System.out.println("警察：小偷要跑。");
                new Thread(){
                    @Override
                    public void run() {
                        ((Security)o).追击();
                    }
                }.start();


            case 4:
                System.out.println("警察：正在追小偷。");


        }
    }
}
